﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using System.Data;
using System.Runtime.Serialization;
using System.Collections.ObjectModel;

namespace GTServices.Entities
{
 
    public class Language : BaseEntity
    {
        [Key]
        public string Name { get; set; }

        public virtual ObservableCollection<FileExtension> FileExtensions { get; set; }

        public Language()
        {
            this.Name = "";
            this.FileExtensions = new ObservableCollection<FileExtension>(); 
        }

        public override void Validate()
        {
            if (String.IsNullOrEmpty(Name))
            {
                throw new ArgumentException("Null or Empty Name");
            }

            if (FileExtensions == null)
            {
                throw new ArgumentException("SubLanguages is Null");
            }
        }

        public override bool Equals(object obj)
        {
            if (!(obj is Language))
            {
                return false;
            }
            return (obj as Language).Name == this.Name;
        }


    }
}
